package io;

import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;

/**
 * 实现用户注册功能
 * 将用户在控制台输入的信息以UserInfo对象形式表示并序列化保存“[用户名].obj”中
 */
public class Test4 {
    public static void main(String[] args) throws IOException {
        //UserInfo userInfo = InputUtil.getInputObject(new UserInfo());
        UserInfo userInfo = InputUtil.getInputObject(new UserInfo(),"欢迎注册");//加个title
        System.out.println(userInfo);

        FileOutputStream fos = new FileOutputStream(userInfo.getUsername()+".obj");
        ObjectOutputStream oos = new ObjectOutputStream(fos);

        oos.writeObject(userInfo);
        System.out.println("写出完毕");
        oos.close();
    }
}
